{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style>
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }

    #title span {
        float: right;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }
</style>
 <body class="gray-bg">
 <div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
        {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='999'}asdlkjasd{/eq}{/present}" href="{:url('imglist',['status'=>999])}{present name='type'}/type/{$type}{/present}{present name='is_face'}/is_face/{$is_face}{/present}">全部</a>
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='0'}asdlkjasd{/eq}{/present}" href="{:url('imglist',['status'=>0])}{present name='type'}/type/{$type}{/present}{present name='is_face'}/is_face/{$is_face}{/present}">审核</a>
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='1'}asdlkjasd{/eq}{else /}asdlkjasd{/present}" href="{:url('imglist',['status'=>1])}{present name='type'}/type/{$type}{/present}{present name='is_face'}/is_face/{$is_face}{/present}">通过</a>
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='-1'}asdlkjasd{/eq}{/present}" href="{:url('imglist',['status'=>-1])}{present name='type'}/type/{$type}{/present}{present name='is_face'}/is_face/{$is_face}{/present}">拒绝</a>
                        <a class="btn btn-default btn-outline {present name='status'}{eq name='status' value='998'}asdlkjasd{/eq}{/present}" href="{:url('imglist',['status'=>998])}{present name='type'}/type/{$type}{/present}{present name='is_face'}/is_face/{$is_face}{/present}">用户删除</a>
                    </div>
                    <div class="fixed-table-toolbar" style="display: flex;">
                        <div>
                        <a class="btn btn-default btn-outline {present name="type"}{else /}asdlkjasd{/present}" href="{:url('imglist')}{present name='status'}/status/{$status}{/present}{present name='is_face'}/is_face/{$is_face}{/present}">全部</a>
                        <a class="btn btn-default btn-outline {eq name='type' value='1'}asdlkjasd{/eq}" href="{:url('imglist',['type'=>'1'])}{present name='status'}/status/{$status}{/present}{present name='is_face'}/is_face/{$is_face}{/present}">今日</a>
                        </div>
                        <div style="margin-left: 30px;">
                        <a class="btn btn-default btn-outline {eq name='is_face' value='0'}asdlkjasd{/eq}" href="{:url('imglist',['is_face'=>'0'])}{present name='type'}/type/{$type}{/present}{present name='status'}/status/{$status}{/present}">全部</a>
                        </div>
                        <a class="btn btn-default btn-outline {eq name='is_face' value='1'}asdlkjasd{/eq}" href="{:url('imglist',['is_face'=>'1'])}{present name='type'}/type/{$type}{/present}{present name='status'}/status/{$status}{/present}">真人</a>
                        </div>
                    </div>
                    <div style="display:block;clear: both;"></div>
                    <div class="fixed-table-toolbar">
                        <form  method="get" action="">
                            <div class="pull-left search">
                                <div class="columns columns-right btn-group pull-left">
                                    <select class="form-control" name="search">
                                        <option value="user_id" {php}if(input('?param.type')){if(input('param.type')=='user_id'){echo "selected";} }{/php}>用户ID</option>
                                        <option value="id" {php}if(input('?param.type')){if(input('param.type')=='id'){echo "selected";} }{/php}>照片ID</option>
                                    </select>
                                </div>
                                {php}
if(input('?param.name')){
{/php} 
<div class="pull-right search">
    <a class="btn btn-w-m btn-link" href="{:url('imglist')}">返回相册管理</a>
</div>{php}
}
{/php}
                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px" class="btn btn-default btn-outline" type="submit">搜索</button>
                                </div>
                                <div class="pull-right search">
                                    <input class="form-control input-outline" type="text"
{php}
if(input('?param.name')){
            if(input('param.name')){
               echo "value='".input('name')."'";
            } 

        }
{/php}
                                     name="name" placeholder="搜索照片">
                                </div>
                                

                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                        <table data-toggle="table">
                            <thead>
                                <tr>
                                  <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">ID</th>
                                    <th data-align="center">管理</th>
                                    <th data-align="center">用户</th>
                                    <th data-align="center">类型</th>
                                    <th data-align="center">真人</th>
                                    <th data-align="center">资源</th>
                                    <th data-align="center">创建时间</th>
                                    <th data-align="center">审核时间</th>
                                    <th data-align="center">审核人</th>
                                    {if condition="isset($status) && $status == 998"}
                                    <th data-align="center">删除时间</th>
                                    {/if}
                                </tr>
                            </thead> 
                            <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.id}"></td>
                                    <td>{$v.id}</td>
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                {if condition="!$v.delete_time"}
                                                {switch name="$v.status"}
                                                {case value="-1"}
                                                <!--<li><a onClick="shenhe({$v.id},'0')">审核</a></li>-->
                                                <li><a onClick="shenhe({$v.id},'1')">通过</a></li>
                                                <li class="divider"></li>
                                                {/case}
                                                {case value="0"}
                                                <li><a onClick="shenhe({$v.id},'1')">通过</a></li>
                                                <li><a onClick="shenhe({$v.id},'-1')">拒绝</a></li>
                                                <li class="divider"></li>
                                                {/case}
                                                {case value="1"}
                                                <!--<li><a onClick="shenhe({$v.id},'-1')">拒绝</a></li>
                                                <li><a onClick="shenhe({$v.id},'0')">审核</a></li>-->
                                                {/case}
                                                {/switch}
                                                {/if}
                                                <li><a onClick="del({$v.id})">删除</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                    <td><a onclick="member('{$v.user_id}')" style="color:#40BCF7">{$v.name}</a><br/>({$v.user_id})</td>
                                    <td>{if condition="$v.is_face==1"}真人{else /}普通{/if}</td>
                                    <td id="real{$v.id}">
                                        {if condition="$v.is_face == 1"}
                                        <span class="btn btn-xs btn-danger" onclick="setRealFace('{$v.id}', 0)">取消真人</span>
                                        {else /}
                                        <span class="btn btn-xs btn-primary" onclick="setRealFace('{$v.id}', 1)">设置真人</span>
                                        {/if}</td>
                                    <td>
                                        {eq name='$v.types' value='1'}
                                        {php}
										// 尝试解析 JSON 数据
										$picData = json_decode($v['pic'], true);
										// 处理图片 URL
										$imageUrl = is_array($picData) && count($picData) > 0 ? $picData[0] : '';
										$imageUrl = strpos($imageUrl, 'http') === false ? '__ROOT__' . $imageUrl : $imageUrl;
										$escapedImageUrl = htmlspecialchars($imageUrl, ENT_QUOTES, 'UTF-8');
										{/php}
										{if condition="$escapedImageUrl"}
										<a href="{$escapedImageUrl}" title="{$v.id}" target="_blank" onclick="lookBigImg('{$escapedImageUrl}')">
										    <img style="max-width:200px" src="{$escapedImageUrl}"/>
										</a>
										{/if}
                                            <!--<a href="__ROOT__{:json_decode($v.pic,true)[0]}" title="{$v.id}" target="_blank">-->
                                            <!--    <img style="max-width:200px" src="__ROOT__{:json_decode($v.pic,true)[0]}"/>-->
                                            <!--</a>-->
                                            <!--{if condition="isset($v.authpic)"}-->
                                            <!--<a href="__ROOT__{$v.authpic}" title="{$v.authpic}" target="_blank">-->
                                            <!--    <img style="max-width:200px" src="__ROOT__{$v.authpic}"/>-->
                                            <!--</a>-->
                                            <!--{/if}-->
                                            <!-- ... 已有代码 ... -->
											{php}
											// 检查 $v.authpic 是否存在且不为空字符串
											if (isset($v['authpic']) && $v['authpic'] !== '') {
											    // 判断 URL 是否包含协议头
											    $authpicUrl = strpos($v['authpic'], 'http') === 0 ? $v['authpic'] : '__ROOT__' . $v['authpic'];
											    // 对 URL 进行转义处理
											    $escapedAuthpicUrl = htmlspecialchars($authpicUrl, ENT_QUOTES, 'UTF-8');
											} else {
											    $escapedAuthpicUrl = '';
											}
											{/php}
											{if condition="$escapedAuthpicUrl"}
											<a href="{$escapedAuthpicUrl}" title="{$v.authpic}" target="_blank" onclick="lookBigImg('{$escapedAuthpicUrl}')">
											    <img style="max-width:200px" src="{$escapedAuthpicUrl}"/>
											</a>
											{/if}
											<!-- ... 已有代码 ... -->
                                            
                                            
                                            
                                            
                                        {else /}
                                            <video src="__ROOT__{:json_decode($v.pic,true)[0]}" controls="controls" style="max-width:200px;"></video>
                                        {/eq}
                                    </td>
                                    <td>{$v.time}</td>
                                    <td>
                                        <span>{neq name="$v.shenhe_time" value="0"}{:date('Y-m-d H:i:s', $v.shenhe_time)}{/neq}</span>
                                    </td>
                                    <td>
                                        <span>{:_getAdminName($v.shenhe_admin_id)}</span>
                                    </td>
                                    {if condition="isset($status) && $status == 998"}
                                    <td data-align="center">
                                        <span>{:date('Y-m-d H:i:s', $v.delete_time)}</span>
                                    </td>
                                    {/if}
                                </tr>
                                {/volist}
                            </tbody>
                        </table>
                        </form>
                    </div>
                </div>  
            </div>
            <hr>
            <div class="row row-lg">
               <div class="col-sm-6">
                    <div class="btn btn-outline btn-default" onclick="alla(1)">
                        批量通过
                    </div>
                    <div class="btn btn-outline btn-default" onclick="alla(0)">
                        批量审核
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="alla(-1)">
                        批量拒绝
                    </div>
                </div> 
                <div class="col-sm-12 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}

<script type="text/javascript">
$(document).ready(function(){
    $('#delidAll').click(function(){
        $('input[type=checkbox]').each(function(){
            var self=$(this);
            if(!self.prop('checked')){
                self.prop('checked',true);
            }else{
                self.prop('checked',false);
            }
        });
    })
});
function del(id){
    swal_del(id,"{:url('imgdel')}")
}

function member(id)
{
    layui.use('layer', function(){
        var layer = layui.layer;
        layer.open({
            title :'预览',
            area: ['100%', '100%'],
            type: 2,
            content: '{:url("member/index")}?search=id&name='+id
        });
    });
}
    function alla(types){
        var all=$(".form-horizontal").serialize();
        var alls=$(".form-horizontal").serializeArray();
       console.log(JSON.stringify(alls))

        ajaxFun("post",'{:url('imglistshenheAll')}?status='+types,all,'json',function(ret){
            
            if(ret){
                swal_msg('操作成功')
                setTimeout(()=>{
                    window.location.reload()
                }, 1500)
            }
        })
         
    }

function shenhe(id,value){
    ajaxFun("post","{:url('authadd')}",{id:id,shenhe:value},'json',function(ret){
        if(ret){
            if(ret.ret){
                layer.msg(ret.ret)
                /*$("#id"+id).hide('fast',function(){
                     $("#id"+id).remove();
                })*/
                window.location.reload()
            }else{
                layer.msg(ret.err)
            }
        }else{
            swal_msg("错误",ret,"error");
        }
    })
}
    function setRealFace(id, state) {
        $.ajax({
            type: 'post',
            url: '{:url("setRealFace")}',
            data: {id, state},
            dataType: 'json',
            success:function(ret){
                if (ret.ret) {
                    let html = state ? `<span class="btn btn-xs btn-danger" onclick="setRealFace('${id}', 0)">取消真人</span>` : `<span class="btn btn-xs btn-primary" onclick="setRealFace('${id}', 1)">设置真人</span>`;
                    $('#real' + id).html(html)
                    layer.msg(ret.ret);
                } else {
                    layer.msg(ret.err);
                }

            },
            error:function(err){
                layer.msg(err)
            }
        });
    }
 
</script>
 